#include "qjscanworddocument.h"

QJScanwordDocument::QJScanwordDocument(const QVector<MVLine> hMatrixValue, const QVector<MVLine> vMatrixValue, const QSize size, QObject *parent) :
    QObject(parent),  m_rowValues(hMatrixValue), m_colValues(vMatrixValue), m_szMatrix(size)
{
    m_Matrix = new uchar[size.width() * size.height()];
    memset(m_Matrix, 0, sizeof(uchar)*size.width() * size.height());
    maxVValueLine = maxMVlineSize(vMatrixValue);
    maxHValueLine = maxMVlineSize(hMatrixValue);
    m_Matrix[size.width() * size.height() - 1] |= 0x02;
    m_Matrix[size.width() * size.height() - 15] |= 0x02;
}

QJScanwordDocument::~QJScanwordDocument()
{
      m_rowValues.clear();
      m_colValues.clear();
      delete[] m_Matrix;
}

uint QJScanwordDocument::maxMVlineSize(const QVector<MVLine>&vValues)
{
    uint max = (int)vValues[0].size();
    for(int i = 1; i < (int)vValues.size(); i++)
    {
        if(max < (uint)vValues[i].size())
            max = (uint)vValues[i].size();
    }
    return max;
}
